package me.jiatao.wan.data.network.okhttp3

import me.jiatao.wan.common.LocalStorage
import okhttp3.Cookie
import okhttp3.CookieJar
import okhttp3.HttpUrl

/**
 * @Author: taojia
 * @CreateDate: 2021/9/8 2:51 下午
 * @Version: 1.0
 * @Description:
 */

class CustomCookieJar : CookieJar {

    override fun loadForRequest(url: HttpUrl): List<Cookie> {
        return LocalStorage.loadCookie(url.host.hashCode().toString())
    }

    override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
        LocalStorage.saveCookie(url.host.hashCode().toString(), cookies)
    }
}